﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace AwesomeEnginePC.Graphics.ThreeDimensional
{
    class Camera
    {
        public Vector3 Position;
        public Vector3 LookAt;
        public Vector3 UpVector;
        public float AspectRatio;
        public Matrix Projection;
        public float FieldOfView;
        public float NearClipPlane;
        public float FarClipPlane;
        public Matrix view;

        public Camera()
        {
            Position = Vector3.Zero;
            LookAt = Vector3.Zero;
            UpVector = Vector3.UnitY;
            FieldOfView = 45.0f;
            NearClipPlane = 1.0f;
            FarClipPlane = 10000.0f;
            SetViewMatrix();
            SetProjectionMatrix();

        }
        public Camera(GraphicsDeviceManager graphics, Vector3 positionIN, Vector3 lookAtIN)
        {
            Position = positionIN;
            LookAt = lookAtIN;
            UpVector = Vector3.UnitY;
            FieldOfView = 45.0f;
            NearClipPlane = 1.0f;
            FarClipPlane = 10000.0f;
            SetViewMatrix();
            SetProjectionMatrix();
        }
        public void SetAspectRatio(GraphicsDeviceManager graphics)
        {
            AspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
                            (float)graphics.GraphicsDevice.Viewport.Height;
        }
        public void SetProjectionMatrix()
        {
            Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
            AspectRatio, 1.0f, 10000.0f);
        }
        public void SetViewMatrix()
        {
            //sets view
            view = Matrix.CreateLookAt(Position, LookAt, Vector3.Up);
        }
    }
}
